Plex.Data.Jax = function(feed, action)
{
	var self = this;
	this.feed = feed;
	this.action = action;
	this.url = "/handlers/Jax/Jax.php";
	this.handler = function(){};
	this.async = true;

	this.V = {};
	this.Var=function(R,L)
	{
		self.V[R]=L;
		return self;
	}

	this.UVar=function(R)
	{
		delete self.V[R];
		return self;
	}

	this.Q=function()
	{
		var Q= new Array();
		for ( X in self.V )
		Q.push(X+"="+self.V[X]);
		return Q.join('&');
	}

	this.Send=function(url,handler,Q)
	{
		var Q = Q ? Q : self.Q();
		var X = new XHR({
			method: 'post',
			async:self.async,
			headers: {
				'Content-type':'application/x-www-form-urlencoded',
				'Content-length':Q.length,
				'Connection':'close'
			},
			onSuccess:handler
		}).send(url,Q);
		
		
	}

	this.Reset=function()
	{
		self.V= new Array();
	}

	this.Call=function()
	{
		self.Var('Feed',self.feed);
		self.Var('Action',self.action);

		var errorCheck = function()
		{
			var	xml=this.response.xml;
			
			var error = xml.getElementsByTagName('error').item(0);
			var response = xml.getElementsByTagName('response').item(0);

			if ( response )
			self.handler(response);
			else if ( error )
			{
				Plex.Lib.JS.load('UI.Widget.Banner');
				banner.open(error.textContent,5);
			}
			else
			{
				var errorMsg = xml.documentElement.textContent.length>0 ? xml.documentElement.textContent : "No Response";
				
				Plex.Lib.JS.load('UI.Widget.Banner');
				banner.open(errorMsg,10);
			}
		}

		self.Send(self.url,errorCheck);
	}
}